<?php
namespace app\service\controller;

use app\common\controller\ServiceOauth;
use external\SFTools;
use think\App;

class Goods extends ServiceOauth {

    public function initialize(){
        parent::initialize();
    }
    
    /**
     * 获取床套SN码列表
     * @param   string  keyword
     * @param   string  fStartDate
     * @param   string  fEndDate
     * @param   string  bc
     * @param   string  page
     * @param   string  size
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function getSnListCt(){
        $keyword = htmlspecialchars(input("post.keyword"));
        $fStartDate = htmlspecialchars(input("post.fStartDate"));
        $fEndDate = htmlspecialchars(input("post.fEndDate"));
        $bc = htmlspecialchars(input("post.bc"));
        $page = htmlspecialchars(input("post.page"));
        $size = htmlspecialchars(input("post.size"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->getSnListCt($keyword, $fStartDate, $fEndDate, $bc, $page, $size);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    
    /**
     * 获取床网SN码列表
     * @param   string  keyword
     * @param   string  fStartDate
     * @param   string  fEndDate
     * @param   string  bc
     * @param   string  page
     * @param   string  size
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function getSnListCw(){
        $keyword = htmlspecialchars(input("post.keyword"));
        $fStartDate = htmlspecialchars(input("post.fStartDate"));
        $fEndDate = htmlspecialchars(input("post.fEndDate"));
        $bc = htmlspecialchars(input("post.bc"));
        $fSupplierCode = htmlspecialchars(input("post.fSupplierCode"));
        $page = htmlspecialchars(input("post.page"));
        $size = htmlspecialchars(input("post.size"));
        $view = htmlspecialchars(input("post.view"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->getSnListCw($keyword, $fStartDate, $fEndDate, $bc, $fSupplierCode, $page, $size, $view);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    
    /**
     * 获取床网SN码列表
     * @param   string  page
     * @param   string  size
     * @param   string  search_value
     * @param   string  type
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function getSnListCtCount(){
        $keyword = htmlspecialchars(input("post.keyword"));
        $fStartDate = htmlspecialchars(input("post.fStartDate"));
        $fEndDate = htmlspecialchars(input("post.fEndDate"));
        $bc = htmlspecialchars(input("post.bc"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->getSnListCtCount($keyword, $fStartDate, $fEndDate, $bc);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    
    /**
     * 获取床网SN码列表
     * @param   string  page
     * @param   string  size
     * @param   string  search_value
     * @param   string  type
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function getSnListCwCount(){
        $keyword = htmlspecialchars(input("post.keyword"));
        $fStartDate = htmlspecialchars(input("post.fStartDate"));
        $fEndDate = htmlspecialchars(input("post.fEndDate"));
        $bc = htmlspecialchars(input("post.bc"));
        $fSupplierCode = htmlspecialchars(input("post.fSupplierCode"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->getSnListCwCount($keyword, $fStartDate, $fEndDate, $bc, $fSupplierCode);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    
    /**
     * 获取床网SN码列表
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function getSupplierListCw(){
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->getSupplierListCw();
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    /**
     * 根据唯一标识删除床套SN码
     * @param   string  barcode_ct_uuid
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function delSnInfoCt(){
        $barcode_ct_uuid = htmlspecialchars(input("post.barcode_ct_uuid"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->delSnInfoCtBuyUUID($barcode_ct_uuid);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
    
    /**
     * 根据唯一标识删除床网SN码
     * @param   string  barcode_ct_uuid
     * @return  json                    Json对象 ( status / code / msg / data )
     */
    public function delSnInfoCw(){
        $barcode_cw_uuid = htmlspecialchars(input("post.barcode_cw_uuid"));
        
        $goodsLogic = new \backend\logic\GoodsLogic;
        $result = $goodsLogic->delSnInfoCwBuyUUID($barcode_cw_uuid);
        
        if (empty($result['error_code'])) {
            return SFTools::pullJson(1, NULL, $result);
        } else {
            return SFTools::pullJson(-1, $result['error_code'], $result['data']);
        }
    }
}
